
import java.util.ArrayList;
import java.util.List;


public class BoxDemo4 {

  public static <U> void addBox(U u, List<Box<U>> boxes) {
    Box<U> box = new Box<>();
    box.add(u);
    boxes.add(box);
  }

  public static <U> void outputBoxes(List<Box<U>> boxes) {
    int counter = 0;
    for (Box<U> box: boxes) {
      U boxContents = box.get();
      System.out.println(
        "Box #" + counter + " contains [" +
        boxContents.toString() + "]");
      counter++;
    }
  }

  public static void main(String[] args) {
      
      Box<Number> numberBox = new Box<> ();
      numberBox.add(5);
      numberBox.add(10.2);
      
      
//    ArrayList<Box<Integer>> listOfIntegerBoxes = new ArrayList<>();
//    BoxDemo4.<Integer>addBox(new Integer(10), listOfIntegerBoxes);
//    BoxDemo4.addBox(120, listOfIntegerBoxes);
//    BoxDemo4.addBox(new Integer(30), listOfIntegerBoxes);
//    BoxDemo4.outputBoxes(listOfIntegerBoxes);
  }
}